import { Client } from "../../dist/esm/index.js";
const send2Son = document.querySelector("#send2Son");
const invokeSon = document.querySelector("#invokeSon");
export const init = async () => {
  const client = new Client({
    target: window.parent,
    handlers: {
      son4info: console.info,
    },
  });
  client.on("load:finish", () => {
    client.send({
      type: "msg",
      data: { name: "son4", msg: "全部加载完成后发送消息" },
    });
  });
  client.mount().on("msg", console.log.bind(null, "son4收到消息"));
  send2Son.addEventListener("click", () => {
    client.send({ type: "msg", data: { name: "son4" } });
  });
  invokeSon.addEventListener("click", () => {
    client.invokeHandler({ type: "son5info", data: ["son4"] });
    client.invokeHandler({ type: "parentLog", data: ["son4"] });
  });
};
